package com.stream;

import java.util.ArrayList;
import java.util.stream.Collectors;

/***
 * @ClassName: StreamTest
 * @Description:
 * @Auther: tanggy3
 * @Date: 17:27 2022/7/28
 * @version : V1.0
 */
public class StreamTest {


    public static void main(String[] args) {
        ArrayList<Integer> integers = new ArrayList<>();
        for (int i = 0; i < 10; i++) {
            integers.add(i);
        }
        integers.stream().map((i)->i*10).sorted().collect(Collectors.toList()).forEach(System.out::println);
        System.out.println(integers.stream().filter((bean) -> bean > 5).max(Integer::max).get());
        integers.stream().filter((bean) -> bean > 5)
                .skip(1L)
                .forEach(System.out::println);
        System.out.println(integers.stream().filter((bean) -> bean > 5)//查出大于5的
                .skip(1L)//跳过一个
                .mapToInt(bean->bean)//转换为IntStream，为了求和
                .sum());
        System.out.println(integers.stream().allMatch(bean -> bean >= 0));//查询是否所有都大于等于0
        System.out.println(integers.stream().max(Integer::compareTo).get());
    }
}
